<?php
/**
 * beimuaihui System
 * Copyright(c) 2011-2020 beimuaihui.
 * @license    http://www.gnu.org/licenses/gpl.html     This software Under GPL V3 License 
 * beimuaihui@gmail.com
 * http://code.google.com/p/beimuaihui/
 * $Id: Tag.php 262 2011-07-23 15:51:14Z beimuaihui $
 */
/**
 * Tag
 *  
 * @author Bob
 * @version 
 */

Zend_Loader::loadClass("Baogg_Db_Table");

class Tag extends Baogg_Db_Table {
	/**
	 * The default table name 
	 */
	protected $_name='';
	protected $_db=null;
	protected $_primary=array(1=>'tag_id');
	public function __construct(){
		$this->_name =   'tag';
		$this->_myPrimary=$this->_primary= "tag_id";
		
		parent::__construct();
	}
	public function getList($where,$order=array("a.ordering desc","a.tag_id desc"),$limit=null){
		$select=$this->_db->select();
		$select->from("{$this->_name} as a","*");
		$select->where(implode(" and ",$where));
		$select->order($order);
		$select->limit($limit['offset'],$limit['size']);	
		return $this->_db->query($select)->fetchAll();
	}
	public function add($params){
		if(!$params || !is_array($params)){
			return 0;
		}
		$row=Baogg_Db::filterColumn($this->_name,$params,$this->_db);
		$affects= $this->insert($row);
		//echo Baogg_Db::debugDb($this->_db);
		return $affects;
	}
	public function getListByName($name){
		$where=array("a.tag_name='{$name}'");
		return $this->getList($where);
	}
}